import { createI18n } from 'vue-i18n'
import type { AppModule } from '~/types'

// 只导入中文和英文语言文件
const messages = {
  cn: import.meta.glob<{ default: any }>('../../locales/cn.yml', { eager: true })['../../locales/cn.yml'].default,
  en: import.meta.glob<{ default: any }>('../../locales/en.yml', { eager: true })['../../locales/en.yml'].default
}

// 默认语言设置为中文
const locale = 'cn'

const i18n = createI18n({
  legacy: false,
  locale,
  messages,
})

export const install: AppModule = (app) => {
  app.use(i18n)
}

export default i18n